import { Injectable } from "@angular/core";
import { Observable, of, Subject } from "rxjs";
import { debounceTime } from "rxjs/operators";

@Injectable({
  providedIn: "root"
})
export class PendingService {
  private arrUrl = [];

  public pending$ = new Subject();

  constructor() {}

  set(v: boolean) {
    this.pending$.next(v);
  }

  push(url: string) {
    this.arrUrl.push(url);
  }

  pop() {
    this.arrUrl.pop();
  }

  private isEmpty() {
    return this.arrUrl.length === 0;
  }

  isComplete() {
    return this.isEmpty();
  }
}
